// Class written be marius brendemoe


#ifndef LOGGER_H // inclusion guard
#define LOGGER_H

#include "LogSys.h"
#include "XMLSettings.h"
#include <string>
#include <sstream>

class Logger
{
private:
  std::string sourceName;
  Level triggerLevel;
  Level currentLevel;
  std::stringstream buffer;
public:
  Logger(const std::string &sourceName);
  ~Logger(void);
  void Log(const std::string &message);
  void Logf(Level level,const char* message, ...);

  //Stream functionality for more modern approach.
  //Logger& operator<<(Level level);
  Logger& operator<<(std::ostream& (*f)(std::ostream&))
  {
	if (currentLevel >= triggerLevel)
	{
		LogSys::getInstance().Write(sourceName,currentLevel,buffer.str());
	}
	buffer.str("");
	return *this;
  }
  template<typename T> Logger& operator<<(const T message){
    if (currentLevel >= triggerLevel)
	{
		buffer << message;
	}
    return *this;
  }
};



#endif // end inclusion guard